<?php
header("content-type:text/html;charset=utf-8");
$redis = new Redis();
$redis->connect("127.0.0.1","6379");
$pdo = new PDO("mysql:host=127.0.0.1;dbname=07c","root","root");
$tel = $_POST['tel'];
$code = $_POST['code'];
$namme = $_POST['name'];
$pwd = $_POST['pwd'];
$time = data("y-m-d H:i:s");
$rediscode = $redis->get("code".$tel);
if($rediscode){
    if($rediscode==$code){
        $sql = "insert into user values('','$name','$pwd','$tel',1,'$time')";
        $res = $pdo->exec($sql);
        if($res){
            $data = array('code'=>0,"msg"=>"注册成功");
        }else{
            $data = array('code'=>2,"msg"=>"注册失败");
        }
    }else{
        $data = array('code'=>1,"msg"=>"验证码输入有误");
    }
}
else{
    $data = array('code'=>3,"msg"=>"验证码失效");
}
echo json_encode($data);
?>